package com.xci.xajtfb.bus.api;

import com.github.lvyanyang.annotation.Authorize;
import com.github.lvyanyang.annotation.RequestJson;
import com.github.lvyanyang.core.BaseController;
import com.github.lvyanyang.core.BoolResult;
import com.github.lvyanyang.core.Const;
import com.github.lvyanyang.core.PageList;
import com.xci.xajtfb.bus.entity.StationInfo;
import com.xci.xajtfb.bus.filter.StationFilter;
import com.xci.xajtfb.bus.service.StationInfoService;
import io.swagger.annotations.*;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * 站点接口
 * @author 张谦 765870682@qq.com
 * @since 2021-03-11 9:50:00
 */
@Authorize
@RestController
@Api(tags = "站点接口")
@RequestMapping(value = "/api/bus/stationInfo", produces =  Const.PROJSON)
public class StationInfoApiController extends BaseController {
    /**
     * 站点服务
     */
    @Resource
    private StationInfoService stationService;

    @ApiOperationSupport(order = 1)
    @ApiOperation(value = "查询站点列表")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "stationName", value = "站点名称", required = true),
            @ApiImplicitParam(name = "longitude", value = "经度", required = true),
            @ApiImplicitParam(name = "latitude", value = "纬度", required = true)})
    //@Authorize(code = "basic.bus.stationInfo.select")
    @PostMapping("/selectList")
    public BoolResult<List<StationInfo>> selectList(@RequestJson String stationName, @RequestJson String longitude, @RequestJson String latitude) {
        return BoolResult.success(stationService.selectList(stationName,longitude,latitude));
    }

    @ApiOperationSupport(order = 2)
    @ApiOperation(value = "查询站点分页列表")
    //@Authorize(code = "basic.bus.stationInfo.select")
    @PostMapping("/selectPageList")
    public BoolResult<PageList<StationInfo>> selectPageList(@RequestBody StationFilter filter) {
        return BoolResult.success(stationService.selectPageList(filter));
    }

    @ApiOperationSupport(order = 3)
    @ApiOperation(value = "通过坐标信息查询公交站点信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "longitude", value = "经度", required = true),
            @ApiImplicitParam(name = "latitude", value = "纬度", required = true),
            @ApiImplicitParam(name = "distance", value = "距离", required = true)})
    //@Authorize(code = "basic.bus.stationInfo.getStationByLonglat")
    @PostMapping("/getStationByLonglat")
    public BoolResult<List<StationInfo>> getStationByLonglat(@RequestJson String longitude, @RequestJson String latitude, @RequestJson String distance) {
        return BoolResult.success(stationService.getStationByLonglat(longitude,latitude,distance));
    }
}
